﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TFile.ISA;
using System.Configuration;
using System.IO;
using TFile.CAD.Repositorios;

namespace TFile.CSA
{
    public class XMLDataService : IXMLDataService
    {
        public void InsertData(string descricao, string arquivo)
        {
            new XMLDataRepositorio().InsertData(descricao, arquivo);
        }

        public void DeleteData(string iddoc)
        {
            new XMLDataRepositorio().DeleteData(iddoc);
        }

        public byte[] GetData()
        {
            string filePath = ConfigurationManager.AppSettings["XMLDocumentos"];

            using (FileStream fs = new FileStream(@filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                byte[] buffer = new byte[fs.Length];
                fs.Read(buffer, 0, (int)fs.Length);
                return buffer;
            }
        }
    }
}
